<?php

namespace api\wxapp\controller;

use cmf\controller\RestBaseController;
use think\captcha\Captcha;

class CaptchaController extends RestBaseController
{
    // 微信小程序用户登录 TODO 增加最后登录信息记录,如 ip
    public function new()
    {
      $sid = input('sid', false);
      if ($sid) {
        session_id($sid);
      }

      $config =    [
        // 验证码字体大小
        'fontSize'    =>    input('font_size', 30),
        // 验证码位数
        'length'      =>    input('length', 4),
        // 关闭验证码杂点
        'useNoise'    =>    false,
        'imageW'    =>    input('width', 0),
        'imageH'    =>    input('height', 0),
      ];
      $captcha = new Captcha($config);
      return $captcha->entry();
    }

}
